import { useRess } from './../store/ress';
import request from "@/util/req";

type loginType<T = undefined> = {
    code:string,
    message:string,
    data:T
}

// 登录
export function login(loginname:string,password:string){
    return request.post
    <any,loginType<{token:string,userid:string}>>
    ('user/login',{
        loginname,
        password
    })
}
// 发送验证码
export function yzm(tel:string){
    return request.post
    <any,loginType<number>>
    ('user/dosendmsgcode',{
        tel
    })
}
// 验证验证码
export function dbYzm(tel:string,telcode:string){
    return request.post
    <any,loginType>
    ('user/docheckcode',{
        tel,
        telcode
    })
}

// 注册
export function zhuce(tel:string,password:string){
    return request.post
    <any,loginType>
    ('user/dofinishregister',{
        tel,
        password
    })
}

// 判断是否被注册
export function dbZC(tel:string){
    return request.post
    <any,loginType>
    ('user/docheckphone',{
        tel
    })
}

// 获取用户详细信息
export function getMyInfo(userid:string){
    return request.get('user/info',{
        params:{
            userid
        }
    })
}

// 修改密码
export function changePass(userid:string,oldpassword:string,newpassword:string){
    return request.get('user/updatePassword',{
        params:{
            userid,
            oldpassword,
            newpassword
        }

    })
}


// 修改用户名
export function changeName(userid:string,username:string){
    return request.get('user/bindusername',{
        params:{
            userid,
            username
        }
    })
}